package cn.org.guhao.practice.redis.controller;

import cn.org.guhao.practice.redis.service.FeignRemote;
import feign.Feign;
import info.boruisi.platform.redis.template.IntegerRedisTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * TestController
 *
 * @author guhao
 * @since 2020/6/7
 */
@RestController
public class TestController {

  private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);


  private final IntegerRedisTemplate integerRedisTemplate;

  public TestController(IntegerRedisTemplate integerRedisTemplate) {
    this.integerRedisTemplate = integerRedisTemplate;
  }

  @GetMapping("/info/{id}")
  public String info(@PathVariable("id") Integer id){
    LOGGER.info("welcome");

    integerRedisTemplate.opsForValue().set("user.id", id);
    LOGGER.info("hello redis");
    FeignRemote remote = Feign.builder().target(FeignRemote.class, "http://www.baidu.com");
    LOGGER.info("content:[{}]", remote.html());

    return "hello world";
  }

}
